// pages/category/category.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    menuData: [],
    bannerUrl:"",
    subMenu:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //后台请求菜单数据

    this.setData({
      menuData: [
{ id: 1005000, name: '居家', bannerUrl: 'http://yanxuan.nosdn.127.net/92357337378cce650797444bc107b0f7.jpg',
          subMenu: ['布艺软装', '被枕', '床品件套', '灯具', '地垫', '床垫', '家饰', '家具', '宠物', '夏凉']
 }, 
{ id: 1005001, name: '餐厨', bannerUrl: 'http://yanxuan.nosdn.127.net/f4ff8b3d5b0767d4e578575c1fd6b921.jpg' ,
  subMenu: ['锅具', '餐具', '清洁', '杯壶', '清洁保鲜', '功能厨具', '茶具咖啡具', '刀剪砧板', '厨房小电']}, 
{ id: 1005002, name: '饮食', bannerUrl: 'http://yanxuan.nosdn.127.net/dd6cc8a7e996936768db5634f12447ed.jpg' ,
  subMenu: ['炒货', '小食', '食材', '冲饮', '糖巧', '糕点', '茗茶', '果干', '肉制品', '调味']}, 
{ id: 1008000, name: '配件', bannerUrl: 'http://yanxuan.nosdn.127.net/cad5aba2bc52d3b8adfd0232c9814de2.jpg' }, 
{ id: 1010000, name: '服装', bannerUrl: 'http://yanxuan.nosdn.127.net/003e1d1289f4f290506ac2aedbd09d35.jpg' }, 
{ id: 1011000, name: '婴童', bannerUrl: 'http://yanxuan.nosdn.127.net/7dc78383e44df530f543659a977740de.jpg' }, 
{ id: 1012000, name: '杂货', bannerUrl: 'http://yanxuan.nosdn.127.net/d233a1a9060a22e8eb0e2b326252eece.jpg' },
 { id: 1013001, name: '洗护', bannerUrl: 'http://yanxuan.nosdn.127.net/ef8c49f8c92d1f86eb76dec0b5bc7cef.jpg' },
  { id: 1019000, name: '志趣', bannerUrl: 'http://yanxuan.nosdn.127.net/99107fbd76eb66cd537213e478189ae1.png' }    
      ]
    })
  },
  tapMenu : function(event){
    //下标
    var index = event.currentTarget.dataset.index;
    this.setData({
      bannerUrl: this.data.menuData[index].bannerUrl,
      subMenu: this.data.menuData[index].subMenu
    })
  }
})